import { Component, EventEmitter, Output } from '@angular/core';
import { FieldType } from 'src/components/scenarios/enums';
import { PlcDataField } from 'src/components/scenarios/models';


@Component({
  selector: 'app-data-field-setting-dialog',
  templateUrl: './data-field-setting-dialog.component.html',
  styleUrl: './data-field-setting-dialog.component.scss'
})
export class DataFieldSettingDialogComponent {
  visible: boolean = false;
  field!: PlcDataField;

  types: FieldType[] = Object.values(FieldType);
  
  @Output()
  editConfirm: EventEmitter<PlcDataField> = new EventEmitter();

  onShow(field: PlcDataField) {
    this.field = { ...field };
    this.visible = true;
  }

  onEditConfirm() {
    this.visible = false;
    this.editConfirm.next(this.field);
  }
  onEditCancel() {
    this.visible = false;
  }
}
